<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>预定义字符类演示</title>
</head>
<body>
</body>
<script>
    //. 任何字符。
    var reg1 = /^.$/;
    console.log(reg1.test("!"));
    var reg2 = /^\.$/;
    console.log(reg2.test("!"));
    //\d 数字：[0-9]
    var reg3 = /^\d$/;
    console.log(reg3.test("a"));
    //\D 非数字:[^0-9]
    var reg4 = /^\D$/;
    console.log(reg4.test("a"));
    //\w 单词字符：[a-zA-Z_0-9]
    var reg5 = /^\w$/;
    console.log(reg5.test("!"));
    //\W 非单词字符:[^\w]
    var reg6 = /^\W$/;
    console.log(reg6.test("1"));
    //\s 空白字符:[ \t\n\x0B\f\r]
    var reg7 = /^\s$/;
    console.log(reg7.test(" "));
    //\S 非空白字符:[^\s]
    var reg7 = /^\S$/;
    console.log(reg7.test("A"));
</script>
</html>